﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WaterBill.DAL;
using WaterBill.DTO;

namespace WaterBill.BUS
{
    class BUS_Bills : DAL_Bills
    {
        DataTable dtB;
        //Lay danh sach tat ca hoa don
        public DataTable BUS_Bills_GetAll()
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetAll();
            }
            catch
            {
            }
            return dtB;
        }

        //Lay danh sach hoa don theo khach hang
        public DataTable BUS_Bills_GetByCustomerId(int CustomerId)
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetByCustomerId(CustomerId);
            }
            catch
            {
            }
            return dtB;
        }

        //Lay danh sach hoa don theo thang su dung
        public DataTable BUS_Bills_GetByChargeId(int ChargeId)
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetByChargeId(ChargeId);
            }
            catch
            {
            }
            return dtB;
        }

        //Lay danh sach hoa don theo khach hang va thang su dung
        public DataTable BUS_Bills_GetByCustomerIdAndChargeId(int CustomerId, int ChargeId)
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetByCustomerIdAndChargeId(CustomerId, ChargeId);
            }
            catch
            {
            }
            return dtB;
        }

        //Lay danh sach hoa don co chi so moi rong va khac thang su dung truyen vao
        public DataTable BUS_Bills_GetNewIndexNullAndOtherChargeMax()
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetNewIndexNullAndOtherChargeMax();
            }
            catch
            {
            }
            return dtB;
        }

        //Lay danh sach hoa don co chi so moi rong va thang su dung la lon nho
        public DataTable BUS_Bills_GetNewIndexNull()
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetNewIndexNull();
            }
            catch
            {
            }
            return dtB;
        }

        //Them mot hoa don mot
        public Boolean BUS_Bills_Insert(DTO_Bills obj)
        {
            try
            {
                if (DAL_Bills_Insert(obj))
                {
                    return true;
                }
            }
            catch
            {
            }
            return false;
        }

        //Sua hoa don
        public Boolean BUS_Bills_Update(DTO_Bills obj)
        {
            try
            {
                if (DAL_Bills_Update(obj))
                {
                    return true;
                }
            }
            catch
            {
            }
            return false;
        }

        //Sua hoa don dua vao billnumber
        public Boolean BUS_Bills_UpdateByBillNumber(DTO_Bills obj)
        {
            try
            {
                if (DAL_Bills_UpdateByBillNumber(obj))
                {
                    return true;
                }
            }
            catch
            {
            }
            return false;
        }

        //Cap nhat trang thai cua hoa don
        public Boolean BUS_Bills_UpdateStatus(DTO_Bills obj)
        {
            try
            {
                if (DAL_Bills_UpdateStatus(obj))
                {
                    return true;
                }
            }
            catch
            {
            }
            return false;
        }

        //Lay Tong Danh Thu
        public DataTable BUS_Bills_GetTotalPrice()
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetTotalPrice();
            }
            catch
            {
            }
            return dtB;
        }

        //Lay Tong Danh Thu theo nam
        public DataTable BUS_Bills_GetYearStats(int start, int end)
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetYearStats(start, end);
            }
            catch
            {
            }
            return dtB;
        }

        //Lay Tong Danh Thu theo thang
        public DataTable BUS_Bills_GetMonthStats(int start, int end, int year)
        {
            dtB = new DataTable();
            try
            {
                dtB = DAL_Bills_GetMonthStats(start, end, year);
            }
            catch
            {
            }
            return dtB;
        }

        //Dem so hoa don dua vao khach hang
        public int BUS_Bills_CountByCustomerId(int CustomerId)
        {
            int count = 0;
            count = DAL_Bills_CountByCustomerId(CustomerId);
            return count;
        }
    }
}
